# class Solution:
#     def resultsArray(self, nums: list[int], k: int) -> list[int]:
#         if k == 1:
#             return nums
#
#
#         result = []
#         bigFlag=True
#         for i in range(len(nums)-1 ):
#             if nums[i] - nums[i + 1] != -1:
#                 bigFlag = False
#                 break
#         if(bigFlag):
#             return nums[k:]
#
#
#
#
#
#         for n in range(len(nums) - k + 1):
#             flag = True
#             for i in range(k - 1):
#                 if nums[n + i] -nums[n + i + 1]!=-1:
#                     result.append(-1)
#                     flag = False
#                     break
#             if flag:
#                 result.append(nums[n + k - 1])
#
#         return result

class Solution():  # 使用计数器去记录 上升的次数连续上升的次数超过k-1 都是大能量数
    def resultsArray(self, nums: list[int], k: int) -> list[int]:
        if (k == 1):
            return nums
        list1 = []
        keys = 0
        for n in range(len(nums) - 1):
            if (nums[n + 1] - nums[n] == 1):
                keys += 1
            else:
                keys = 0
            if (n >= k - 2):
                if (keys >= k - 1):
                    list1.append(nums[n + 1])
                else:
                    list1.append(-1)
        return list1


# 示例
lll = Solution()
print(lll.resultsArray([1, 4, ], 1))
